home *** CD-ROM | disk | FTP | other *** search
/ PC-X 1997 October / pcx14_9710.iso / swag / delphi.swg / 0033_Use LZ Compress in DELPHI.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-11-22  |  1.5 KB  |  38 lines

  1.  
  2. {If you wan't to use LZ compression from inside Delphi there is a couple of API function calls that
  3. you can use to do the trick.  But they only let you Uncompress the file! And not Compress it!
  4. Well that is what I have foud anyway.
  5. Here is an extract example from a program that I have written a while ago:}
  6.  
  7. procedure TForm1.Decomp;
  8. var
  9.   StringFIName, StringFOName : String;
  10.   FIStruct, FOStruct         : TOFStruct;
  11.   HandleFOpen, HandleFWrite  : Integer;
  12.   success                    : LongInt;
  13. begin
  14.   {Open the Input File that is Compressed}
  15.   StringFIName  := FileListBox1.Filename + #0;
  16.   PIFileName    := @StringFIName;
  17.   HandleFOpen   := LZOpenFile(@StringFIName[1], FIStruct, OF_READ or OF_PROMPT);
  18.   if HandleFOpen < 0 then
  19.     MessageDlg('Error Opening Input File : '+ StringFIName, mtInformation,
  20.     [mbOk], 0);
  21.   {Open the Output File that is Uncompressed!}
  22.   StringFOName  := 'c:\WallP.bmp' + #0;
  23.   POFileName    := @StringFOName;
  24.   HandleFWrite  := LZOpenFile(@StringFOName[1], FOStruct, OF_CREATE);
  25.   if HandleFWrite < 0 then
  26.     MessageDlg('Error Creating Output File' + StringFOName, mtInformation, [mbOk], 0);
  27.   {Now we can copy/Uncompress the file}
  28.   success := LZCopy(HandleFOpen, HandleFWrite);
  29.   if success < 0 then
  30.     MessageDlg('Error Copying Input File to Output File', mtInformation, [mbOk], 0);
  31.   {All finished, so lets Close the Input File}
  32.   LZClose(HandleFOpen);
  33.   LZClose(HandleFWrite);
  34. end;
  35.  
  36. You will need to add LZEXPAND in the Uses clause as well.
  37.  
  38.